home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
AMIGA
/
(A)Z
/
(A)Z8.ADF
/
Nart
/
rnd.asm
< prev
next >
Wrap
Assembly Source File
|
1986-07-05
|
1KB
|
46 lines
*\ RND.ASM From: AMIGA.3955
* :ts=8 bk=0
* Yet Another random number generator. By Leo Schwab.
* Based on an idea posted on the USENET (Thanks, Sam Dicker!)
* For the MetaComCo assembler
*
* Calling convention:
* long rnd (range);
* long range;
*
* Assembling:
* df1:c/assem rnd.asm -o rnd.o
*
* 8606.30
*/
section code
xdef _rnd
_rnd lea rndseed,a0 Get address of seed
move.l 4(sp),d1 Get range argument
tst.l d1
ble.s setseed Go reset seed
move.l (a0),d0 Get seed
ADD.L D0,D0
BHI.S over
EORI.L #$1D872B41,D0
over
move.l d0,(a0) Save new seed
andi.l #$ffff,d0 Coerce into word
andi.l #$ffff,d1
divu d1,d0 Divide by range
swap d0 and get remainder (modulus)
ext.l d0
rts
setseed neg.l d1 Probably don't need this
move.l d1,(a0)
rts
section data
rndseed dc.l 0
end